css: Actually break at end of the string
authorBenjamin Otte <otte@redhat.com>
Wed, 21 May 2014 17:17:21 +0000 (19:17 +0200)
committerBenjamin Otte <otte@redhat.com>
Thu, 22 May 2014 00:13:49 +0000 (02:13 +0200)
Introduced in 65c4c1555d0634c063c3aa354620de260e4aaf7f.

Found by gnome-continuous running the testsuite.

Includes fixing a broken test in the testsuite.

gtk/gtkcssparser.c
gtk/gtkcssstringvalue.c
testsuite/css/parser/Makefile.am
testsuite/css/parser/string-values.ref.css [new file with mode: 0644]

index de78ae6fb10f32e2c77407e698afe2a5bdeed361..644592bc92c7edb033f9ebe231eee6fe10ad2646 100644 (file)
@@ -1025,13 +1025,13 @@ _gtk_css_print_string (GString    *str,
   g_string_append_c (str, '"');
 
   do {
-    len = strcspn (string, "\"\n\r\f");
+    len = strcspn (string, "\\\"\n\r\f");
     g_string_append_len (str, string, len);
     string += len;
     switch (*string)
       {
       case '\0':
-        break;
+        goto out;
       case '\n':
         g_string_append (str, "\\A ");
         break;
@@ -1054,6 +1054,7 @@ _gtk_css_print_string (GString    *str,
     string++;
   } while (*string);
 
+out:
   g_string_append_c (str, '"');
 }
 
index 5da9fefbcc19b1b7512ad130d038ed229d1da07f..56ccc692e2d8fa2b3273770953978dbd025070b6 100644 (file)
@@ -88,7 +88,7 @@ gtk_css_value_ident_print (const GtkCssValue *value,
     switch (*string)
       {
       case '\0':
-        break;
+        goto out;
       case '\n':
         g_string_append (str, "\\A ");
         break;
@@ -113,6 +113,9 @@ gtk_css_value_ident_print (const GtkCssValue *value,
       }
     string++;
   } while (*string);
+
+out:
+  ;
 }
 
 static const GtkCssValueClass GTK_CSS_VALUE_STRING = {
index 846b93833e7783add2c468f4c306abeb76b2e4a6..084a340a3dcd28d8f0d8ce8d60659908e348ef16 100644 (file)
@@ -334,6 +334,7 @@ test_data = \
        single-slash.errors\
        single-slash.ref.css \
        string-values.css \
+       string-values.ref.css \
        test.png \
        transition.css \
        transition.ref.css \
diff --git a/testsuite/css/parser/string-values.ref.css b/testsuite/css/parser/string-values.ref.css
new file mode 100644 (file)
index 0000000..491a023
--- /dev/null
@@ -0,0 +1,27 @@
+n {
+  font-family: "\A ";
+}
+
+r {
+  font-family: "\C ";
+}
+
+f {
+  font-family: "\D ";
+}
+
+a {
+  font-family: "\"";
+}
+
+b {
+  font-family: "'";
+}
+
+c {
+  font-family: "'";
+}
+
+d {
+  font-family: "\\";
+}